﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using TRPOP.Common;
using TRPOP.CMS.Web.UI;


using TRPOP.CMS.Business;
using TRPOP.CMS.Model;
using Newtonsoft.Json;
using System.Text.RegularExpressions;
using TRPOP.Config;

namespace TRPOP.CMS.Web.Admin
{
    public partial class Node_syncContent : BaseAdmin
    {
        #region 当前页面权限验证
        protected override void SubPageInit()
        {
            base.m_SubPagePermission = Plugin.PermissionKeys.PermissionEnum.Node_Save;
        }
        #endregion

        #region 页面变量
        protected int m_nodeid = 0;
        protected NodeInfo m_NodeInfo = new NodeInfo();
        protected NodeManage m_NodeManage = new NodeManage();
        #endregion

        #region 页面事件
        protected void Page_Load(object sender, EventArgs e)
        {
            m_nodeid = RequestHelper.RequestInt("nodeid");
            if (m_nodeid > 0)//验证用户对结点的权限
                base.AlertForNoPermission(base.CheckIsHavePermission(m_nodeid));
            if (!IsPostBack)
            {
                LoadBase();
            }
        }
        #endregion

        #region 页面方法

        public void LoadBase()
        {
            m_NodeInfo = m_NodeManage.GetInfoById(m_nodeid);
            if (m_NodeInfo == null || m_NodeInfo.NodeTypeId != (int)NodeType.EnumElement.VirualNode)
            {
                Alert("结点信息不正确");
                base.End();
            }
            NodeInfo oParentInfo = m_NodeManage.GetInfoById(m_NodeInfo.InheritNodeID);
            if (oParentInfo == null)
            {
                Alert("父节点不存在");
                base.End();
            }
            new ContentManage().UpdateAllSyncContent(m_NodeInfo, oParentInfo, (base.m_IAdminUser.getUserBaseInfo() as TRPOP.CMS.UserManage.AdminUserInfo).UserBaseId);
            base.Redirect("../publish/content_list.aspx?nodeid=" + m_NodeInfo.NodeId);
        }
        #endregion

    }
}
